<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>AdWords API Documentation</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta><link rel="stylesheet" href="../css/template.css" type="text/css"></link></head><body><div id="content"><h1 class="file">Common/Util/Logger.php</h1><div id="file-nav-box"><div id="file-nav-container"><ul id="file-nav"><li><a href="#classes"><img src="../images/icons/class.png" alt="Class" height="14"></img>
                          Classes
                      </a><ul><li><a href="#\Logger">\Logger</a></li></ul></li></ul><div style="clear: left;"></div></div><div id="file-nav-tab">
              Table of Contents
          </div></div><a name="top" class="anchor"></a><div id="file-description"><div class="short-description">A logger class which registers appenders (any writable handle location
which can be fopen'ed) with a unique name for that log</div><div class="long-description"><p>PHP version 5</p>

<p>Copyright 2011, Google Inc. All Rights Reserved.</p>

<p>Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at</p>

<pre><code>http://www.apache.org/licenses/LICENSE-2.0
</code></pre>

<p>Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</p></div></div><dl class="file-info"><dt>Author</dt><dd>Adam Rogal
         
    </dd><dt>Author</dt><dd>Eric Koleda
         
    </dd><dt>Author</dt><dd>Vincent Tsao
         
    </dd><dt>Category</dt><dd>WebServices
         
    </dd><dt>Copyright</dt><dd>2011, Google Inc. All Rights Reserved.
         
    </dd><dt>License</dt><dd>http://www.apache.org/licenses/LICENSE-2.0 Apache License,
            Version 2.0
         
    </dd><dt>Package</dt><dd>GoogleApiAdsCommon
         
    </dd><dt>Subpackage</dt><dd>Util
         
    </dd></dl><a name="classes" class="anchor"></a><a id="\Logger" class="anchor"></a><h2 class="class">\Logger<div class="to-top"><a href="#top">jump to top</a></div></h2><div class="class"><small class="package"><b>Package: </b>GoogleApiAdsCommon\Util</small><div class="short-description">A logger class which registers appenders (any writable handle location
which can be fopen'ed) with a unique name for that log.</div><div class="long-description"><p>The library will
write all incoming/outgoing SOAP XML to <var>SOAP_XML_LOG</var> and
all records of requests to <var>REQUEST_INFO_LOG</var>.</p>

<p>Currently, levels are only used as indicators (there is no filtering
mechanism as of yet).</p>

<p>A list of supported appenders (file handles) can be found here:
<a href="http://us2.php.net/manual/en/wrappers.php">http://us2.php.net/manual/en/wrappers.php</a></p></div><dl class="class-info"></dl><h3>Properties</h3><div><a id="\Logger::$DEBUG" class="anchor"></a><div class="property public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img>string <span class="highlight">$DEBUG</span> = 'DEBUG'</code><div class="description"><span class="attribute">static</span><div class="short-description">DEBUG level.</div></div><div class="code-tabs"><div class="long-description"></div><strong>Default value</strong><code>'DEBUG'</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>string</dd></dl></div><div class="clear"></div></div><a id="\Logger::$ERROR" class="anchor"></a><div class="property public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img>string <span class="highlight">$ERROR</span> = 'ERROR'</code><div class="description"><span class="attribute">static</span><div class="short-description">ERROR level.</div></div><div class="code-tabs"><div class="long-description"></div><strong>Default value</strong><code>'ERROR'</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>string</dd></dl></div><div class="clear"></div></div><a id="\Logger::$FATAL" class="anchor"></a><div class="property public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img>string <span class="highlight">$FATAL</span> = 'FATAL'</code><div class="description"><span class="attribute">static</span><div class="short-description">FATAL level.</div></div><div class="code-tabs"><div class="long-description"></div><strong>Default value</strong><code>'FATAL'</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>string</dd></dl></div><div class="clear"></div></div><a id="\Logger::$INFO" class="anchor"></a><div class="property public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img>string <span class="highlight">$INFO</span> = 'INFO'</code><div class="description"><span class="attribute">static</span><div class="short-description">INFO level.</div></div><div class="code-tabs"><div class="long-description"></div><strong>Default value</strong><code>'INFO'</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>string</dd></dl></div><div class="clear"></div></div><a id="\Logger::$REQUEST_INFO_LOG" class="anchor"></a><div class="property public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img>string <span class="highlight">$REQUEST_INFO_LOG</span> = 'request_info'</code><div class="description"><span class="attribute">static</span><div class="short-description">Logs all information about requests.</div></div><div class="code-tabs"><div class="long-description"></div><strong>Default value</strong><code>'request_info'</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>string</dd></dl></div><div class="clear"></div></div><a id="\Logger::$SOAP_XML_LOG" class="anchor"></a><div class="property public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img>string <span class="highlight">$SOAP_XML_LOG</span> = 'soap_xml'</code><div class="description"><span class="attribute">static</span><div class="short-description">Logs all incomming and outgoing SOAP XML.</div></div><div class="code-tabs"><div class="long-description"></div><strong>Default value</strong><code>'soap_xml'</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>string</dd></dl></div><div class="clear"></div></div><a id="\Logger::$STD_ERR_STREAM" class="anchor"></a><div class="property public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img>string <span class="highlight">$STD_ERR_STREAM</span> = 'php://stderr'</code><div class="description"><span class="attribute">static</span><div class="short-description">Standard error stream for use with the LogToStream method.</div></div><div class="code-tabs"><div class="long-description"></div><strong>Default value</strong><code>'php://stderr'</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>string</dd><dt>See</dt><dd>\self::LogToStream()
         
    </dd></dl></div><div class="clear"></div></div><a id="\Logger::$STD_OUT_STREAM" class="anchor"></a><div class="property public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img>string <span class="highlight">$STD_OUT_STREAM</span> = 'php://stdout'</code><div class="description"><span class="attribute">static</span><div class="short-description">Standard out stream for use with the LogToStream method.</div></div><div class="code-tabs"><div class="long-description"></div><strong>Default value</strong><code>'php://stdout'</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>string</dd><dt>See</dt><dd>\self::LogToStream()
         
    </dd></dl></div><div class="clear"></div></div><a id="\Logger::$logLevelMap" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$logLevelMap</span> = array()</code><div class="description"><span class="attribute">static</span></div><div class="code-tabs"><strong>Default value</strong><code>array()</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\Logger::$logToMap" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$logToMap</span> = array()</code><div class="description"><span class="attribute">static</span></div><div class="code-tabs"><strong>Default value</strong><code>array()</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\Logger::$timeFormat" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$timeFormat</span> = 'M d Y H:i:s.u'</code><div class="description"><span class="attribute">static</span></div><div class="code-tabs"><strong>Default value</strong><code>'M d Y H:i:s.u'</code><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div></div><h3>Methods</h3><div><a id="\Logger::Log()" class="anchor"></a><div class="method public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">Log</span><span class="nb-faded-text">(string $log, string $message, string $level = NULL)</span> : void</code><div class="description"><span class="attribute">static</span><p class="short_description">Logs a message to the log at a specific level.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$log</th><td>string</td><td><em><p>the unique name of the log</p></em></td></tr><tr><th>$message</th><td>string</td><td><em><p>the message to write</p></em></td></tr><tr><th>$level</th><td>string</td><td><em><p>the level at which to write the message</p></em></td></tr></table></div><div class="clear"></div></div><a id="\Logger::LogTo()" class="anchor"></a><div class="method private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">LogTo</span><span class="nb-faded-text">(string $log, string $handleLocation)</span> : void</code><div class="description"><span class="attribute">static</span><p class="short_description">Logs the log to a handle location which can be any writable stream.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$log</th><td>string</td><td><em><p>the unique name of the log</p></em></td></tr><tr><th>$handleLocation</th><td>string</td><td><em><p>the location of the handle to fopen</p></em></td></tr></table><strong>Details</strong><dl class="function-info"><dt>Access</dt><dd>private
         
    </dd></dl></div><div class="clear"></div></div><a id="\Logger::LogToAllAppenders()" class="anchor"></a><div class="method private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">LogToAllAppenders</span><span class="nb-faded-text">(string $log, string $message, string $level)</span> : void</code><div class="description"><span class="attribute">static</span><p class="short_description">Logs the message at a specific level to all appenders for that log.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$log</th><td>string</td><td><em><p>the unique name of the log</p></em></td></tr><tr><th>$message</th><td>string</td><td><em><p>the message to write</p></em></td></tr><tr><th>$level</th><td>string</td><td><em><p>the level at which to write the message</p></em></td></tr></table><strong>Details</strong><dl class="function-info"><dt>Access</dt><dd>private
         
    </dd></dl></div><div class="clear"></div></div><a id="\Logger::LogToAppenders()" class="anchor"></a><div class="method private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">LogToAppenders</span><span class="nb-faded-text">(array $appenders, string $message, string $level)</span> : void</code><div class="description"><span class="attribute">static</span><p class="short_description">Writes the message to all appenders (any writable handle location that
can be fopen'ed) at a specific level.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$appenders</th><td>array</td><td><em><p>the appenders to write to</p></em></td></tr><tr><th>$message</th><td>string</td><td><em><p>the message to write</p></em></td></tr><tr><th>$level</th><td>string</td><td><em><p>the level at which to write the message</p></em></td></tr></table><strong>Details</strong><dl class="function-info"><dt>Access</dt><dd>private
         
    </dd></dl></div><div class="clear"></div></div><a id="\Logger::LogToFile()" class="anchor"></a><div class="method public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">LogToFile</span><span class="nb-faded-text">(string $log, string $filePath)</span> : void</code><div class="description"><span class="attribute">static</span><p class="short_description">Logs the given log to a file at the file path.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$log</th><td>string</td><td><em><p>the unique name of the log</p></em></td></tr><tr><th>$filePath</th><td>string</td><td><em><p>the location of the file to append the log to</p></em></td></tr></table></div><div class="clear"></div></div><a id="\Logger::LogToStream()" class="anchor"></a><div class="method public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">LogToStream</span><span class="nb-faded-text">(string $log, string $phpIoStream)</span> : void</code><div class="description"><span class="attribute">static</span><p class="short_description">Logs the given log to a stream represented by <var>$phpIoStream</var>.</p></div><div class="code-tabs"><div class="long-description"><p>The
availble streams are listed here:</p>

<p><a href="http://us3.php.net/manual/en/wrappers.php.php">http://us3.php.net/manual/en/wrappers.php.php</a></p>

<p>The variables <var>$STD_OUT_STREAM</var> and <var>$STD_ERR_STREAM</var> are
provided for your convenience.</p></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$log</th><td>string</td><td><em><p>the unique name of the log</p></em></td></tr><tr><th>$phpIoStream</th><td>string</td><td><em><p>the php I/O stream of the form php://*</p>
</em></td></tr></table><strong>Details</strong><dl class="function-info"><dt>See</dt><dd>\self::$STD_OUT_STREAM
         
    </dd><dt>See</dt><dd>\self::$STD_ERR_STREAM
         
    </dd></dl></div><div class="clear"></div></div><a id="\Logger::SetLogLevel()" class="anchor"></a><div class="method public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">SetLogLevel</span><span class="nb-faded-text">(string $log, string $level)</span> : void</code><div class="description"><span class="attribute">static</span><p class="short_description">Sets the logging level for a given log.</p></div><div class="code-tabs"><div class="long-description"><p>Only messages at that log level
or higher will be written to the log.</p></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$log</th><td>string</td><td><em><p>the unique name of the log</p></em></td></tr><tr><th>$level</th><td>string</td><td><em><p>the level to filter for</p></em></td></tr></table></div><div class="clear"></div></div><a id="\Logger::ShouldLog()" class="anchor"></a><div class="method private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">ShouldLog</span><span class="nb-faded-text">(string $logLevel, string $messageLevel)</span> : void</code><div class="description"><span class="attribute">static</span><p class="short_description">Determines if a message of a given level should be written to a log of a
given level.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$logLevel</th><td>string</td><td><em><p>the level of the log</p></em></td></tr><tr><th>$messageLevel</th><td>string</td><td><em><p>the level of the message</p></em></td></tr></table></div><div class="clear"></div></div><a id="\Logger::WriteMessage()" class="anchor"></a><div class="method private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">WriteMessage</span><span class="nb-faded-text">(string $handleLocation, string $message, string $level)</span> : void</code><div class="description"><span class="attribute">static</span><p class="short_description">Writes a message with the prepended time and level to the handle
location.</p></div><div class="code-tabs"><div class="long-description"><p>The handle will be opened, written to and then closed.</p></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$handleLocation</th><td>string</td><td><em><p>the location of the handle that will be
    fopen'ed</p>
</em></td></tr><tr><th>$message</th><td>string</td><td><em><p>the message to write</p></em></td></tr><tr><th>$level</th><td>string</td><td><em><p>the level of the message</p></em></td></tr></table><strong>Details</strong><dl class="function-info"><dt>Access</dt><dd>private
         
    </dd></dl></div><div class="clear"></div></div><a id="\Logger::__construct()" class="anchor"></a><div class="method private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">__construct</span><span class="nb-faded-text">()</span> : void</code><div class="description"><p class="short_description">The Logger class is not meant to have any instances.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Details</strong><dl class="function-info"><dt>Access</dt><dd>private
         
    </dd></dl></div><div class="clear"></div></div></div></div></div><small class="footer">
            Documentation was generated by
            <a href="http://phpdoc.org">phpDocumentor
                2.0.0a12</a>.
        </small></body></html>
